import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { PageTool } from "../../../../common/global/PageTool";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { TilePanel } from "../../equipment/TilePanel";
import { ArenaCrossFinalMyBetRankCellRenderer } from "./cell/ArenaCrossFinalMyBetRankCellRenderer";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { SArenaCrossMyBetInfos } from "../../../../../Message/Public/SArenaCrossMyBetInfos";
import { EffectManager } from "../../../manager/EffectManager";
import { Cache } from "../../../cache/Cache";
import { MuiEvent } from "../../../../../com/mui/events/MuiEvent";
import { EPrictUnit } from "../../../../../Message/Public/EPrictUnit";
import { GTabBar } from "../../../../../com/mui/controls/GTabBar";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class ArenaCrossFinalMyBetRankWindow
    
    export  class ArenaCrossFinalMyBetRankWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._ary = [];
            this._showArray = [];
            this.glowFilterY = new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
            this.filterArr = [this.glowFilterY];
            this._pageTool = new PageTool([], 10);
            setSize(500, 485);
            titleHeight = 47;
            title = Language.getString(44319);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        protected onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossFinalGetMyBetInfos));
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc2=null;
            super.createChildren();
            this._tabBar = ObjCreate.createGTabBar(16, 33, Language.getArray(44380), 63, 22, this, this.onTabBarChangeHandler);
            this._sp = new Object /* flash.display.Sprite */();
            this._sp.x = 18;
            this._sp.y = 58;
            addChild(this._sp);
            this._coinSprite = new Object /* flash.display.Sprite */();
            this._coinSprite.x = 18;
            this._coinSprite.y = 58;
            addChild(this._coinSprite);
            this._goldSprite = new Object /* flash.display.Sprite */();
            this._goldSprite.x = 18;
            this._goldSprite.y = 58;
            addChild(this._goldSprite);
            this._coinSprite.visible = true;
            this._goldSprite.visible = false;
            ObjCreate.createBg(0, 0, 464, 368, this._sp);
            ObjCreate.createTextField(Language.getString(44316), 38, 8, 36, 20, this._sp, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44321), 122, 8, 60, 20, this._sp, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44322), 222, 8, 60, 20, this._sp, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44323), 315, 8, 36, 20, this._sp, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44320), 388, 8, 60, 20, this._sp, GlobalStyle.textFormat6);
            this._tfNoRecord = ObjCreate.createTextField(Language.getString(44240), 218, 208, 200, 20, this, GlobalStyle.textFormat6);
            this._tfNoRecord.visible = true;
            this._tileList = new TilePanel();
            this._tileList.setSize(450, 330);
            this._tileList.rowHeight = 33;
            this._tileList.columnWidth = 445;
            this._tileList.setStyle("cellRenderer", ArenaCrossFinalMyBetRankCellRenderer);
            this._tileList.x = 2;
            this._tileList.y = 28;
            this._sp.addChild(this._tileList);
            this._tileList.visible = false;
            this._pagebar = new PageSelecter();
            this._pagebar.mode = PageSelecter.CompleteMode;
            this._pagebar.move(100, 372);
            this._pagebar.currentPage = 1;
            this._pagebar.addEventListener(flash.events.Event.CHANGE, this.onCurPageChangeHandler);
            this._sp.addChild(this._pagebar);
            this._stDectTx = ObjCreate.createTextField(Language.getString(70443), 60, 397, 360, 20, this._coinSprite, GlobalStyle.textFormat5);
            var loc1=ObjCreate.createTextField(Language.getString(44312), 265, 375, 53, 20, this._coinSprite, new GTextFormat(FontUtil.songtiName, 12, 16776960));
            loc2 = ResouceConst.getScaleBitmap(ImagesConst.DisabledBg);
            loc2.x = 317;
            loc2.y = 372;
            loc2.setSize(64, 22);
            this._coinSprite.addChild(loc2);
            var loc3=ObjCreate.createTextField(Language.getString(44310), 381, 375, 20, 20, this._coinSprite);
            ObjCreate.createBitmap(ImagesConst.Tongqian_small, 394, 375, this._coinSprite);
            this._txReward = ObjCreate.createTextField("0", 318, 373, 60, 20, this._coinSprite, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._getRewardBtn = ObjCreate.createGButton(Language.getString(44313), 414, 372, 50, 22, this._coinSprite);
            this._getRewardBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBetBtnClick);
            this._acReward = ObjCreate.createTextField(Language.getString(44385), 328, 390, 70, 20, this._goldSprite, new GTextFormat(FontUtil.songtiName, 12, 16776960));
            this._acReward.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        protected onBetBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossFinalGetMyRewards));
            return;
        }

        protected onCurPageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this._tileList.dataProvider = new DataProvider(this._pageTool.getByPageNo(this._pagebar.currentPage));
            return;
        }

        public updateInfo(arg1: SArenaCrossMyBetInfos): void
        {
            this._ary = arg1.betInfos.concat();
            this.onTabBarChangeHandler(null);
            var loc1=this._ary.length > 0;
            this._tileList.visible = loc1;
            this._tfNoRecord.visible = !loc1;
            this._reward = arg1.betReward;
            this._txReward.text = this._reward.toString();
            if (this._reward > 0) 
            {
                EffectManager.glowFilterReg(this._getRewardBtn, this.filterArr, 0.8, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._getRewardBtn);
            }
            return;
        }

        public updateMoney(): void
        {
            this._acReward.text = Language.getStringByParam(44386, Cache.instance.role.money.arenaCrossCoin);
            return;
        }

        public updateMyRewardNum(): void
        {
            this._txReward.text = "0";
            this._acReward.text = Language.getStringByParam(44386, 0);
            EffectManager.glowFilterUnReg(this._getRewardBtn);
            return;
        }

        /* internal  */onTabBarChangeHandler(arg1: MuiEvent): void
        {
            this.changeShowByTab();
            this.onCurPageChangeHandler(null);
            return;
        }

        /* internal  */changeShowByTab(): void
        {
            var loc1=0;
            var loc3=null;
            this._showArray = [];
            var loc2=this._tabBar.selectedIndex;
            if (loc2 != 0) 
            {
                loc1 = EPrictUnit._EPriceUnitGold;
                this._acReward.text = Language.getStringByParam(44386, Cache.instance.role.money.arenaCrossCoin);
                this._coinSprite.visible = false;
                this._goldSprite.visible = true;
                this._pagebar.move(176, 372);
            }
            else 
            {
                loc1 = EPrictUnit._EPriceUnitCoin;
                this._coinSprite.visible = true;
                this._goldSprite.visible = false;
                this._pagebar.move(100, 372);
            }
            var loc4=0;
            while (loc4 < this._ary.length) 
            {
                loc3 = this._ary[loc4];
                if (loc3.betUnit == loc1) 
                {
                    this._showArray.push(loc3);
                }
                ++loc4;
            }
            this._pageTool.array = this._showArray;
            this._pagebar.maxPage = this._pageTool.pagesCount;
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(ArenaCrossFinalMyBetRankWindow._instance == null);
        }

        public static get instance(): ArenaCrossFinalMyBetRankWindow
        {
            if (!ArenaCrossFinalMyBetRankWindow._instance) 
            {
                ArenaCrossFinalMyBetRankWindow._instance = new ArenaCrossFinalMyBetRankWindow();
            }
            return ArenaCrossFinalMyBetRankWindow._instance;
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_sp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_tfNoRecord: Object /* flash.text.TextField */;

        /* internal */ /* var */_tileList: TilePanel;

        /* internal */ /* var */_pagebar: PageSelecter;

        /* internal */ /* var */_ary: Array<any>;

        /* internal */ /* var */_showArray: Array<any>;

        /* internal */ /* var */_stDectTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_coinSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_goldSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_getRewardBtn: GButton;

        /* internal */ /* var */_txReward: Object /* flash.text.TextField */;

        /* internal */ /* var */_acReward: Object /* flash.text.TextField */;

        /* internal */ /* var */_reward: int;

        /* internal */ /* var */glowFilterY: Object /* flash.filters.GlowFilter */;

        /* internal */ /* var */filterArr: Array<any>;

        /* internal */ /* var */_pageTool: PageTool;

        /* internal */ static /* var */_instance: ArenaCrossFinalMyBetRankWindow;
    }
